<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">出口管理</ui:define>
    <ui:define name="content">
        <h:form>
            <p:dialog header="执行操作中,请稍后" widgetVar="doing" modal="true" closable="false" resizable="false"
                      draggable="false"/>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton value="批量模式"
                                         icon="fa fa-list-ul"
                                         actionListener="#{loanApplicationExportListBean.changeModeToBatch}"
                                         update="@form"
                                         process="@this"
                                         rendered="#{loanApplicationExportListBean.isNotBatch()}"/>

                        <p:commandButton value="常规模式" icon="fa fa-file"
                                         actionListener="#{loanApplicationExportListBean.changeModeToNormal}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{loanApplicationExportListBean.isBatch()}"/>

                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>

                        <p:columnToggler datasource="exportInfoDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"
                                         rendered="#{loanApplicationExportListBean.isNormal()}"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         actionListener="#{loanApplicationExportListBean.onReset}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{loanApplicationExportListBean.isNormal()}"/>
                        <p:commandButton value="删除" icon="fa fa-remove"
                                         actionListener="#{loanApplicationExportListBean.onBatchDelete}"
                                         update="@form"
                                         rendered="#{loanApplicationExportListBean.isBatch()}"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         rendered="#{loanApplicationExportListBean.isBatch()}"
                                         ajax="false">
                            <p:dataExporter type="xls" target="exportInfoDataTable" fileName="export"/>
                        </p:commandButton>
                        <p:commandButton icon="fa fa-plus" value="新增"
                                         action="#{loanApplicationExportListBean.onAdd}"
                                         rendered="#{loanApplicationExportListBean.isNormal()}">
                            <f:setPropertyActionListener value="/views/application/export/list.xhtml"
                                                         target="#{currentUserBean.back}"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="4" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-5,ui-grid-col-1,ui-grid-col-5"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:left;">

                                <p:outputLabel value="产品"/>
                                <p:selectCheckboxMenu value="#{loanApplicationExportListBean.$.products}"
                                                      label="- 请选择 - " filter="true" filterMatchMode="startsWith" multiple="true">
                                    <f:selectItems
                                            value="#{loanApplicationExportListBean.commProductIds}"
                                            var="prod"
                                            itemLabel="#{prod.name}" itemValue="#{prod.productId}"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel value="平台"/>
                                <p:selectManyButton value="#{loanApplicationExportListBean.$.platforms}">
                                    <f:selectItem itemLabel="ios" itemValue="ios"/>
                                    <f:selectItem itemLabel="android" itemValue="android"/>
                                </p:selectManyButton>

                                <p:outputLabel value="出口类型"/>
                                <p:selectOneButton value="#{loanApplicationExportListBean.$.type}">
                                    <f:selectItems
                                            value="#{loanApplicationExportListBean.dictionaries[DictionaryCode.EXPORT_TYPE]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneButton>
                                <p:outputLabel value="所属组"/>
                                <p:selectOneMenu value="#{loanApplicationExportListBean.$.exportGroupId}" filter="true">
                                    <f:selectItem itemLabel="- 请选择 - " noSelectionOption="true"/>
                                    <f:selectItems value="#{loanApplicationExportListBean.exportGroup}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="status" value="是否上线"/>
                                <p:selectOneButton id="status" value="#{loanApplicationExportListBean.$.status}">
                                    <f:selectItem itemValue="1" itemLabel="上线"/>
                                    <f:selectItem itemValue="0" itemLabel="下线"/>
                                </p:selectOneButton>
                                <p:outputLabel value="在线时间"/>
                                <p:outputPanel>
                                    <p:calendar value="#{loanApplicationExportListBean.$.startTime}"
                                                styleClass="autoWidthCalendar"
                                                locale="#{constants:get('LOCALE')}"
                                                timeZone="#{constants:get('TIME_ZONE')}"
                                                pattern="#{constants:get('DATETIME_FORMAT')}"
                                                navigator="true"
                                                readonlyInput="true"/>
                                    <span>— </span>
                                    <p:calendar value="#{loanApplicationExportListBean.$.endTime}"
                                                styleClass="autoWidthCalendar"
                                                locale="#{constants:get('LOCALE')}"
                                                timeZone="#{constants:get('TIME_ZONE')}"
                                                pattern="#{constants:get('DATETIME_FORMAT')}"
                                                navigator="true"
                                                readonlyInput="true"/>
                                </p:outputPanel>

                                <p:outputLabel value="版本限制"/>
                                <p:outputPanel>
                                    <p:inputNumber
                                            value="#{loanApplicationExportListBean.$.minVersion}"
                                            styleClass="autoWidthCalendar"
                                            decimalPlaces="0"/>
                                    <span>— </span>
                                    <p:inputNumber value="#{loanApplicationExportListBean.$.maxVersion}"
                                                   styleClass="autoWidthCalendar"
                                                   decimalPlaces="0"/>
                                </p:outputPanel>

                                <p:outputLabel for="title" value="名称"/>
                                <p:inputText id="title" value="#{loanApplicationExportListBean.$.name}"/>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="exportInfoDataTable"
                                         style="width: 100%"
                                         var="exportInfo"
                                         value="#{loanApplicationExportListBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="97%"
                                         reflow="true"
                                         selection="#{loanApplicationExportListBean.selectedRecords}"
                                         resizableColumns="true"
                                         rendered="#{security:areAllGranted('LOAN_FAMILY_TAGS_FIRST_PARTY_SEARCH')}">


                                <p:column headerText="操作" rendered="#{loanApplicationExportListBean.isNotBatch()}" style="text-align:center;width: 100px">
                                    <p:splitButton icon="fa fa-eye"
                                                   action="#{loanApplicationExportListBean.onEdit(exportInfo.id)}"
                                                   process="@this">
                                        <f:setPropertyActionListener
                                                value="/views/application/export/list.xhtml"
                                                target="#{currentUserBean.back}"/>
                                        <p:menuitem value="上线" icon="fa fa-arrow-up"
                                                    actionListener="#{loanApplicationExportListBean.online(exportInfo.id)}"
                                                    onstart="PF('doing').show()"
                                                    process="@this" update="@form"
                                                    rendered="#{exportInfo.status == 0}"/>

                                        <p:menuitem value="下线" icon="fa fa-arrow-down"
                                                    actionListener="#{loanApplicationExportListBean.offline(exportInfo.id)}"
                                                    onstart="PF('doing').show()"
                                                    process="@this" update="@form"
                                                    rendered="#{exportInfo.status == 1 }"/>

                                        <p:menuitem value="删除" icon="fa fa-fw fa-remove"
                                                    actionListener="#{loanApplicationExportListBean.onDelete(exportInfo.id)}"
                                                    process="@this" update="@form">
                                            <p:confirm header="提示信息" message="是否确定删除?" icon="ui-icon-alert"/>
                                        </p:menuitem>
                                    </p:splitButton>
                                </p:column>
                                <p:column selectionMode="multiple" style="width:16px;text-align:center"
                                          rendered="#{loanApplicationExportListBean.isBatch()}"/>
                                <p:column headerText="名称" style="text-align: center">
                                    <h:outputText value="#{exportInfo.name}"/>
                                </p:column>
                                <p:column headerText="产品" style="text-align: center;width: 100px">
                                    <p:rowToggler />
                                </p:column>
                                <p:column headerText="平台" style="text-align: center;width: 100px">
                                    <h:outputText value="#{exportInfo.platforms}" escape="false"/>
                                </p:column>

                                <p:column headerText="页面" style="text-align: center">
                                    <h:outputText value="#{exportInfo.pageName}"/>
                                </p:column>
                                <p:column headerText="分组名称" style="text-align: center">
                                    <h:outputText value="#{exportInfo.groupName}"/>
                                </p:column>
                                <p:column headerText="图片（点击前）"  style="width: 100px;">
                                    <p:graphicImage url="#{exportInfo.imgBefore}" width="100px"/>
                                </p:column>
                                <p:column headerText="图片（点击后）"  style="width: 100px;">
                                    <p:graphicImage url="#{exportInfo.imgAfter}" width="100px"/>
                                </p:column>
                                <p:column headerText="状态" style="text-align: center;width: 70px">
                                    <h:outputText style="font-weight: bold; color: red" value="下线" rendered="#{exportInfo.status == 0}"/>
                                    <h:outputText style="font-weight: bold; color: green" value="上线" rendered="#{exportInfo.status == 1}"/>
                                </p:column>
                                <p:column headerText="位置" style="text-align: center;width: 70px">
                                    <h:outputText value="#{exportInfo.position}"/>
                                </p:column>

                                <p:rowExpansion>
                                    <p:panel  style="min-height: 110px;margin-right: 20px;white-space: pre-wrap">
                                        <h:outputText value="#{exportInfo.products}" escape="false" />
                                    </p:panel>
                                </p:rowExpansion>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>